package actions;

//~--- non-JDK imports --------------------------------------------------------

import beans.SectionBean;

import client.TopicsPosts;

import dto.Sections;
import dto.Topics;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

//~--- JDK imports ------------------------------------------------------------



import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SectionAction extends org.apache.struts.action.Action {
    Sections         forums;
    TopicsPosts      posts;
    Vector<Sections> sec;
    Vector<Topics>   topic;

    public SectionAction() {
        posts  = new TopicsPosts();
        forums = new Sections();
    }

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                                 HttpServletResponse response)
            throws Exception {
        ActionForward forward = new ActionForward();

        posts.getParentSection();
        forums = posts.getMainForum();
        posts.getInsideSection(forums);
        sec   = posts.getInnerSections();
        topic = posts.getInnerTopics();

        Integer sectionid = forums.getSectionid();

        if ((sec.size() != 0) || (topic.size() != 0)) {
            ((SectionBean) form).setSections(sec);
            forward = mapping.findForward("done");
        } else {
            forward = mapping.findForward("fail");
        }

        return forward;
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
